package cn.monkey.family.data.shop.item;

import cn.monkey.family.data.EntityMapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class ItemMapper extends EntityMapper<ItemDto, Item, ItemVo> {
    @Override
    @Mapping(target = "creator", source = "creatorId", qualifiedByName = "getUserIdAndNamePairFromId")
    @Mapping(target = "updater", source = "updaterId", qualifiedByName = "getUserIdAndNamePairFromId")
    public abstract ItemVo toVo(Item item);

    @Override
    public abstract Item toEntity(ItemDto itemDto);
}
